package el

import (
	"aiAutoPilot/robot/utils"
	"fmt"
	"github.com/playwright-community/playwright-go"
	"time"
)

var elBrowser playwright.Browser = nil

func openPage(url string) playwright.Frame {

	if elBrowser == nil {
		elBrowser = utils.StartBrowser()
	}

	page := utils.OpenPage(elBrowser, url)

	//还没加载
	page.WaitForEvent("framenavigated")

	var imFrame playwright.Frame
	for _, frame := range page.Frames() {
		if frame.URL() == "https://ejia.tbea.com/im/xiaoxi/" {
			imFrame = frame

		}
	}
	fmt.Println("完成消息iframe加载")
	time.Sleep(500)
	return imFrame

}

func RunElWebRobot(action string) {

	//imFrame := openPage("https://el.21tb.com/race-mobile/client/static/index.html")

}
